package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.CheckInConfigDto;
import com.zzyl.dto.CheckInDto;
import com.zzyl.dto.ContractDto;
import com.zzyl.service.CheckInConfigService;
import com.zzyl.service.CheckInService;
import com.zzyl.service.ContractService;
import com.zzyl.vo.retreat.TasVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkIn")
@Api(tags = "入住")
public class CheckInController {

    @Autowired
    private CheckInService checkInService;

    /**
     * 发起入住申请
     * @param dto
     * @return
     */
    @PostMapping("/create")
    public ResponseResult createCheckIn(@RequestBody CheckInDto dto){
        return checkInService.createCheckIn(dto);
    }

    /**
     * 查询入住表单
     * @param assigneeId 处理人ID
     * @param code 入住编码
     * @param flowStatus 流程状态
     * @param taskId 任务ID
     * @return
     */
    @GetMapping
    public ResponseResult<TasVo> getCheckIn(String assigneeId, String code, Integer flowStatus, String taskId){

        ResponseResult<TasVo> responseResult = checkInService.getCheckIn(assigneeId, code, flowStatus, taskId);
        return responseResult;
    }

    /**
     * 护理主管评估
     * @param dto
     * @return
     */
    @PostMapping("/review")
    public ResponseResult review(@RequestBody CheckInDto dto){
        ResponseResult responseResult = checkInService.review(dto);
        return responseResult;
    }

    /**
     * 副院长审批-通过
     * @param id 入住ID
     * @param message 意见
     * @param taskId 任务ID
     * @return
     */
    @PutMapping("/submit")
    public ResponseResult submit(
            @RequestParam(required = true) Long id,
            @RequestParam(required = true) String message,
            @RequestParam(required = true) String taskId){

        return checkInService.submit(id, message, taskId);
    }

    /**
     * 副院长审批-拒绝
     * @param id 入住ID
     * @param message 意见
     * @param taskId 任务ID
     * @return
     */
    @PutMapping("/reject")
    public ResponseResult reject(
            @RequestParam(required = true) Long id,
            @RequestParam(required = true) String message,
            @RequestParam(required = true) String taskId){

        return checkInService.reject(id, message, taskId);
    }

    /**
     * 副院长审批-驳回
     * @param id 入住ID
     * @param message 意见
     * @param taskId 任务ID
     * @return
     */
    @PutMapping
    public ResponseResult disapprove(
            @RequestParam(required = true) Long id,
            @RequestParam(required = true) String message,
            @RequestParam(required = true) String taskId){

        return checkInService.disapprove(id, message, taskId);
    }

    /**
     * 副院长-撤回
     * @param flowStatus 流程状态
     * @param id 入住ID
     * @param taskId 任务ID
     * @return
     */
    @PutMapping ("/revocation")
    public ResponseResult revocation(
            Integer flowStatus,
            Long id,
            String taskId
    ){
        return checkInService.revocation(flowStatus, id, taskId);
    }

    /**
     * 申请人-撤销
     * @param id 入住ID
     * @param taskId 任务ID
     * @return
     */
    @PutMapping ("/cancel")
    public ResponseResult cancel(
            Long id,
            String taskId
    ){
        return checkInService.cancel(id, taskId);
    }

    @Autowired
    private CheckInConfigService checkInConfigService;

    /**
     * 养老顾问-入住选配
     * @param dto
     * @return
     */
    @PostMapping
    public ResponseResult checkIn(@RequestBody CheckInConfigDto dto){
        return checkInConfigService.checkIn(dto);
    }

    @Autowired
    private ContractService contractService;

    /**
     * 法务专员-签约办理
     * @param dto
     * @return
     */
    @PostMapping("/sign")
    public ResponseResult sign(@RequestBody ContractDto dto){
        return contractService.sign(dto);
    }
}
